import React, { Component } from 'react';
import './index.scss';

class DomTest extends Component {

    constructor(props){
        super(props);
        this.container = React.createRef();
    }

    canvasSupport = e => {
        return !!e.getContext
    }

    addElement = () => {
        const container = this.container.current;
        const canvas = document.createElement('canvas');

        if(this.canvasSupport(canvas)){
            container.appendChild(canvas);
        }else{
            // 对不支持canvas做对于处理
        }
    }

    

    componentDidMount(){
        this.addElement()
    }

    render() {
        return <div ref={this.container}>
            
        </div>
    }
}

export default DomTest